

<div class="layui-form" lay-filter="layuiadmin-form-role" id="form">
    <form id="change_pwd" lay-filter="aa">
        <div class="layui-form-item">
            <label class="layui-form-label">当前密码</label>
            <div class="layui-input-inline">
                <input type="password" name="before_pwd" autocomplete="off" lay-verify="required" class="layui-input"> <!-- lay-verify="required" -->
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="after_pwd" autocomplete="off" lay-verify="required"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">确认新密码</label>
            <div class="layui-input-inline">
                <input type="password" name="after_pwd_confim" autocomplete="off" lay-verify="required"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                <a  class="layui-btn" lay-submit style="width: 200px;" lay-filter="form-submit1">保存</a>
            </div>
        </div>
    </form>
</div>

<script>
    layui.use(['admin','form'],function(admin,form){
        form.on('submit(form-submit1)',function(data){

            var $ = layui.jquery;
            var _this=this;
            var loading = $(this).find('.layui-icon');
            var before_pwd = $('input[name="before_pwd"]').val();
            var after_pwd = $('input[name="after_pwd"]').val();
            var pwd = $('input[name="after_pwd_confim"]').val();
            if(after_pwd != pwd){
                layer.msg('两次登录密码不一致');
                return false;
            }
            layui.admin.formapi('admins/update_pwd',data.field,2);
            return false;
        })
    })
</script>
